﻿using Architecture.API.Application.TraceabilityCommand.AuxiliaryMaterialsCommand;
using MediatR;
using Traceability.Domain.Service.AuxiliaryMaterialsServices;
using Traceability.Domain.TraceabilityDto;

namespace Architecture.API.Application.TraceabilityCommandHandler.AuxiliaryMaterialsCommandHanler
{
    /// <summary>
    /// 
    /// </summary>
    public class ShowAuxiliaryMaterialsCommandHanler : IRequestHandler<ShowAuxiliaryMaterialsCommand, List<AuxiliaryMaterialsDto>>
    {
        /// <summary>
        /// 辅料服务
        /// </summary>
        protected readonly IAuxiliaryMaterialsService auxiliaryMaterialsService;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="auxiliaryMaterialsService">辅料服务</param>
        public ShowAuxiliaryMaterialsCommandHanler(IAuxiliaryMaterialsService auxiliaryMaterialsService)
        {
            this.auxiliaryMaterialsService = auxiliaryMaterialsService;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<List<AuxiliaryMaterialsDto>> Handle(ShowAuxiliaryMaterialsCommand request, CancellationToken cancellationToken)
        {
            return await auxiliaryMaterialsService.GetAllAuxiliaryMaterialsList(request.shoppingId);
        }
    }
}
